AmCharts.addInitHandler(function(chart){function loadFile(t,a,r,e){if(void 0===e&&(e="dataProvider"),r.showCurtain&&showCurtain(void 0,r.noStyles),l.remaining++,window.XMLHttpRequest)var i=new XMLHttpRequest;else var i=new ActiveXObject("Microsoft.XMLHTTP");i.onreadystatechange=function(){if(4==i.readyState&&404==i.status)raiseError(__("Error loading the file")+": "+t,!1,r);else if(4==i.readyState&&200==i.status){switch(void 0===r.format&&(r.format="json"),r.format=r.format.toLowerCase(),r.format){case"json":a[e]=postprocess(parseJSON(i.responseText,r),r);break;case"csv":a[e]=postprocess(parseCSV(i.responseText,r),r);break;default:raiseError(__("Unsupported data format")+": "+r.format,o,r.noStyles)}if(l.remaining--,0===l.remaining){if(r.async)if("map"===chart.type)chart.validateNow(!0);else if(chart.validateData(),l.startDuration)if("stock"===chart.type){chart.panelsSettings.startDuration=l.startDuration;for(var n in chart.panels)chart.panels[n].startDuration=l.startDuration,chart.panels[n].animateAgain()}else chart.startDuration=l.startDuration,chart.animateAgain();"stock"!==chart.type||r.reloading||chart.periodSelector.setDefaultPeriod(),removeCurtain()}r.reload&&(r.timeout&&clearTimeout(r.timeout),r.timeout=setTimeout(loadFile,1e3*r.reload,t,a,r),r.reloading=!0)}};try{i.open("GET",r.timestamp?timestampUrl(t):t,r.async),i.send()}catch(o){raiseError(__("Error loading the file")+": "+t,o,r)}}function parseJSON(response,options){try{return void 0!==JSON?JSON.parse(response):eval(response)}catch(e){return raiseError(__("Error parsing JSON file")+": "+l.url,e,options),[]}}function parseCSV(t,a){var r=CSVToArray(t,a.delimiter),e=[],i=[];a.useColumnNames&&(i=r.shift(),0<a.skip&&a.skip--);for(var o=0;o<a.skip;o++)r.shift();for(var n;n=a.reverse?r.pop():r.shift();){for(var s={},o=0;o<n.length;o++){var l=void 0===i[o]?"col"+o:i[o];s[l]=n[o]}e.push(s)}return e}function postprocess(t,a){if(void 0===a.postProcess||!isFunction(a.postProcess))return t;try{return a.postProcess.call(this,t,a)}catch(r){return raiseError(__("Error loading file")+": "+a.url,!1,a),t}}function isArray(t){return t instanceof Array}function isObject(t){return"object"==typeof t}function isFunction(t){return"function"==typeof t}function applyDefaults(t){for(var a in defaults)setDefault(t,a,defaults[a])}function setDefault(t,a,r){void 0===t[a]&&(t[a]=r)}function raiseError(t,a,r){r.showErrors?showCurtain(t,r.noStyles):(removeCurtain(),console.log(t))}function __(t){return void 0!==chart.language&&void 0!==AmCharts.translations.dataLoader[chart.language]&&void 0!==AmCharts.translations.dataLoader[chart.language][t]?AmCharts.translations.dataLoader[chart.language][t]:t}function showCurtain(t,a){removeCurtain(),void 0===t&&(t=__("Loading data..."));var r=document.createElement("div");r.setAttribute("id",chart.div.id+"-curtain"),r.className="amcharts-dataloader-curtain",!0!==a?(r.style.position="absolute",r.style.top=0,r.style.left=0,r.style.width=(void 0!==chart.realWidth?chart.realWidth:chart.divRealWidth)+"px",r.style.height=(void 0!==chart.realHeight?chart.realHeight:chart.divRealHeight)+"px",r.style.textAlign="center",r.style.display="table",r.style.fontSize="20px",r.style.background="rgba(255, 255, 255, 0.3)",r.innerHTML='<div style="display: table-cell; vertical-align: middle;">'+t+"</div>"):r.innerHTML=t,chart.containerDiv.appendChild(r),l.curtain=r}function removeCurtain(){try{void 0!==l.curtain&&chart.containerDiv.removeChild(l.curtain)}catch(t){}l.curtain=void 0}function timestampUrl(t){var a=t.split("?");return 1===a.length?a[1]=(new Date).getTime():a[1]+="&"+(new Date).getTime(),a.join("?")}function CSVToArray(t,a){a=a||",";for(var r=new RegExp("(\\"+a+"|\\r?\\n|\\r|^)"+'(?:"([^"]*(?:""[^"]*)*)"|'+'([^"\\'+a+"\\r\\n]*))","gi"),e=[[]],i=null;i=r.exec(t);){var o=i[1];if(o.length&&o!=a&&e.push([]),i[2])var n=i[2].replace(new RegExp('""',"g"),'"');else var n=i[3];e[e.length-1].push(n)}return e}void 0!==chart.dataLoader&&isObject(chart.dataLoader)||(chart.dataLoader={});var version=chart.version.split(".");if(!(Number(version[0])<3||3==Number(version[0])&&Number(version[1])<13)){var l=chart.dataLoader;l.remaining=0;var defaults={async:!0,format:"json",showErrors:!0,showCurtain:!0,noStyles:!1,reload:0,timestamp:!1,delimiter:",",skip:0,useColumnNames:!1,reverse:!1,reloading:!1};if("stock"===chart.type)setTimeout(function(){0>chart.panelsSettings.startDuration&&(l.startDuration=chart.panelsSettings.startDuration,chart.panelsSettings.startDuration=0);for(var t in chart.dataSets){var a=chart.dataSets[t];void 0!==a.dataLoader&&void 0!==a.dataLoader.url&&(a.dataProvider=[],applyDefaults(a.dataLoader),loadFile(a.dataLoader.url,a,a.dataLoader,"dataProvider")),void 0!==a.eventDataLoader&&void 0!==a.eventDataLoader.url&&(a.events=[],applyDefaults(a.eventDataLoader),loadFile(a.eventDataLoader.url,a,a.eventDataLoader,"stockEvents"))}},100);else{if(applyDefaults(l),void 0===l.url)return;void 0!==chart.startDuration&&0<chart.startDuration&&(l.startDuration=chart.startDuration,chart.startDuration=0),chart.dataProvider=[],loadFile(l.url,chart,l,"dataProvider")}}},["pie","serial","xy","funnel","radar","gauge","stock","map"]);
//# sourceMappingURL=dataloader.min.map.js